/*
 * Copyright (C) 2017-2021
 * All rights reserved, Designed By
 * Copyright authorization contact 18814114118
 */
package com.shop.cereshop.app.dao.shop;

import com.shop.cereshop.app.page.comment.*;
import com.shop.cereshop.app.page.product.BroadCastDTO;
import com.shop.cereshop.app.page.product.BuyerComment;
import com.shop.cereshop.app.param.comment.CommentParam;
import com.shop.cereshop.app.param.comment.CommentWorParam;
import com.shop.cereshop.app.param.comment.QueryProductCommentDTO;
import com.shop.cereshop.commons.domain.shop.CereShopComment;
import com.shop.cereshop.commons.domain.word.CerePlatformWord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface CereShopCommentDAO extends BaseMapper<CereShopComment> {

    int insertSelective(CereShopComment record);

    List<BuyerComment> findByProductId(@Param("productId") Long productId);

    CereShopComment findShop(@Param("productId") Long productId);

    List<SelfComment> getAll(CommentParam param);

    Long findTotal(@Param("buyerUserId") Long buyerUserId, @Param("state") Integer state);

    CereShopComment findByOrderId(@Param("orderId") Long orderId);

    List<CerePlatformWord> findWords();

    ShopCommentVO getById(@Param("commentId") Long commentId, @Param("buyerUserId") Long buyerUserId);

    List<WordComment> getProductAll(CommentWorParam param);

    int findProductNumber(@Param("orderId") Long orderId);

    void updateBuyerData(@Param("buyerUserId") Long buyerUserId, @Param("id") Long id);

    CereShopComment findComment(@Param("buyerUserId") Long buyerUserId, @Param("orderId") Long orderId, @Param("skuId") Long skuId);

    List<SelfComment> getCommentList(CommentParam param);

    List<SelfComment> getUnCommentList(CommentParam param);

    List<BroadCastDTO> findRecentComment(@Param("productId") Long productId,
                                         @Param("oneHourAgo") String oneHourAgo);

    CommentCount getProductCommentCount(Long productId);

    List<BuyerComment> getProductComments(@Param("productId") Long productId, @Param("filter") Integer filter, @Param("buyerUserId") Long buyerUserId);


    List<ProductCommentVO> getProductCommentList(QueryProductCommentDTO param);

    List<ProductCommentVO> getRepliesByParentIds(@Param("parentIds") List<Long> parentIds, @Param("buyerUserId") Long buyerUserId);


    List<ReplyCommentVO> getReplyComments(@Param("commentId") Long commentId);

    @Update("UPDATE cere_shop_comment SET view_count = IFNULL(view_count, 0) + 1 WHERE comment_id = #{commentId}")
    void addViewCount(@Param("commentId") Long commentId);

    List<CereShopComment> getShopAvgStar();


    List<CereShopComment> getProductAvgStar();

    List<CereShopComment> getShopComments();

}
